package pwd.allen.util;

import java.lang.reflect.Field;

/**
 * @create 2019-09-25 11:32
 **/
public class ReflectUtil {

    /**
     * 获取field
     * @param c
     * @param fieldName
     * @return
     */
    public static Field getField(Class c, String fieldName) {
        Field field = null;
        try {
            field = c.getDeclaredField(fieldName);
        } catch (NoSuchFieldException e) {
        }
        if (field == null && c.getSuperclass() != null) {
            field = getField(c.getSuperclass(), fieldName);
        }
        return field;
    }
}
